import json
import sys
sys.path.append('../')
from matplotlib import pyplot as plt
from matplotlib import gridspec
import matplotlib
from utils import *
f = open('Data/metadata.json')
metadata = json.load(f)
# view metadata present in the file
metadata
{'min_pitch': 165,
'max_pitch': 440,
'start_time': 500,
'duration': 30,
'vocal_audio_path': 'Data/NIR_VS_Bhoop_Vox.wav',
'mix_audio_path': 'Data/NIR_VS_Bhoop_StereoMix.wav',
'cycle_file': 'Data/NIR_VS_Bhoop_Metre_VilambitEktal-edited.csv',
'tonic': 220,
'notes': [{'label': 'P_', 'cents': -500},
{'label': 'D_', 'cents': -300},
{'label': 'S', 'cents': 0},
{'label': 'R', 'cents': 200},
{'label': 'G', 'cents': 400},
{'label': 'P', 'cents': 700},
{'label': 'D', 'cents': 900},
{'label': "S'", 'cents': 1200},
{'label': "R'", 'cents': 1400},
{'label': "G'", 'cents': 1600},
{'label': "P'", 'cents': 1900}],
'num_div': 4}
playAudio(audioPath=metadata['mix_audio_path'], startTime=metadata['start_time'], duration=metadata['duration'])
%%capture
# initialise figure, with 3 subplots
fig, axs = generateFig(3, (14, 7), [2, 3, 3])
# plot waveplot
axs[0] = drawWave(audioPath=metadata['mix_audio_path'], startTime=metadata['start_time'], duration=metadata['duration'], ax=axs[0], annotate=True, cyclePath=metadata['cycle_file'], numDiv=metadata['num_div'], annotLabel=False)
# plot spetogram
axs[1] = spectrogram(audioPath=metadata['mix_audio_path'], startTime=metadata['start_time'], duration=metadata['duration'], cmap='Blues', ax=axs[1], yticks=True, annotate=True, cyclePath=metadata['cycle_file'], numDiv=metadata['num_div'], annotLabel=False)
# plot pitch contour
axs[2] = pitchCountour(audioPath=metadata['vocal_audio_path'], startTime=metadata['start_time'], duration=metadata['duration'], minPitch=metadata['min_pitch'], maxPitch=metadata['max_pitch'], notes=metadata['notes'], tonic=metadata['tonic'], ax=axs[2], annotate=True, cyclePath=metadata['cycle_file'], numDiv=metadata['num_div'], xticks=True, yticks=True)
# display figure
fig